<template>
  <div>
    <div class="now_page_title">
      <div class="left_box">
        <div class="breadcrumb_boxs">
          <div v-for="(item, index) in stratBreadList" :key="item.id">
            <div :class="{ text_color: index == stratBreadList.length - 1 }">
              <span class="icon_class">/</span>
              <el-tooltip class="item" effect="dark" :content="item.label" placement="top">
                <span class="breadcrumb_box_item" @click="breadRouterClick(item)">{{ item.label }}</span>
              </el-tooltip>
            </div>
          </div>
          <div v-for="(item, index) in breadList" :key="item.id">
            <div v-if="breadList.length < 4" :class="{ text_color: index == breadList.length - 1 }">
              <span class="icon_class">/</span>
              <el-tooltip class="item" effect="dark" :content="item.label" placement="top">
                <span class="breadcrumb_box_item" @click="breadRouterClick(item)">{{ item.label }}</span>
              </el-tooltip>
            </div>
            <div v-else :class="{ text_color: index == breadList.length - 1 }">
              <div v-if="index == 0">
                <span class="icon_class">/</span>
                <el-tooltip class="item" effect="dark" :content="item.label" placement="top">
                  <span class="breadcrumb_box_item" @click="breadRouterClick(item)">{{ item.label }}</span>
                </el-tooltip>
              </div>
              <div v-if="index >= breadList.length - 2">
                <span v-if="index == breadList.length - 2" class="icon_class">/ &nbsp; ... &nbsp;/</span>
                <span v-if="index == breadList.length - 1" class="icon_class">/</span>
                <el-tooltip class="item" effect="dark" :content="item.label" placement="top">
                  <span class="breadcrumb_box_item" @click="breadRouterClick(item)">{{ item.label }}</span>
                </el-tooltip>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang='ts' name="breadcrumb-navigation-doc">

const props = defineProps({
  pageType: {
    //enterprise:企业,team:团队,self:个人
    type: String,
    default: "",
  },
  stratBreadList: {
    type: Array,
    default: () => {
      return [];
    },
  },
  breadList: {
    type: Array,
    default: () => {
      return [];
    },
  },
})
const pageType = ref(props.pageType)
const stratBreadList: any = ref()
const breadList: any = ref()
console.log();
watch(
  () => props.stratBreadList,
  (newValue, oldValue) => {
    stratBreadList.value = newValue
  }
)
watch(
  () => props.breadList,
  (newValue, oldValue) => {
    breadList.value = newValue
  }
)
const emit = defineEmits(['breadRouterClick'])
/**面包屑点击事件 */
const breadRouterClick = (item: any) => {
  emit("breadRouterClick", item);
}
</script>
<style scoped lang="scss">
.now_page_title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  padding: 0 20px;
  border-bottom: 1px solid #eee;
  font-family: "Microsoft YaHei";

  .left_box {
    display: flex;
    align-items: center;
    color: #999;
    font-size: 15px;
  }

  .metaTitle {
    margin-left: 8px;
    color: #333;
  }
}

.breadcrumb_boxs {
  width: 100%;
  height: 48px;
  display: flex;
  align-items: center;
  overflow: hidden;
  overflow-x: auto;
  white-space: nowrap;
  color: #999;

  .text_color {
    color: #333;
  }

  .icon_class {
    margin-left: 5px;
    margin-right: 5px
  }

  .breadcrumb_box_item {
    // display: inline-block;
    // vertical-align: middle;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 170px;
    // height: 18px;
    cursor: pointer;

    &:hover {
      color: #409eff;
    }
  }
}
</style>
